package com.webside.series.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webside.base.baseservice.impl.AbstractService;
import com.webside.playbackstatistics.config.PlayStatisticsConfig;
import com.webside.playbackstatistics.model.StatRankings;
import com.webside.series.mapper.BvideoEntityMapper;
import com.webside.series.mapper.SeriesMapper;
import com.webside.series.model.Bdictionary;
import com.webside.series.model.BvideoEntity;
import com.webside.series.model.SeriesEntity;
import com.webside.series.service.BdictionaryService;
import com.webside.series.service.DealSeriesService;
import com.webside.series.service.SeriesService;

@Service("DealSeriesService")
public class DealSeriesServiceImpl extends AbstractService<SeriesEntity, Long> implements DealSeriesService {
	@Autowired
	private BdictionaryService bdictionaryService;
	@Autowired
	private SeriesService seriesService;

	// 根据参数查询查询当前的所有未处理剧集集合
	@Override
	public Map dealSeriesAllList(SeriesEntity series) {
		// TODO Auto-generated method stub
		// 返回的集合数据信息
		Map dealSeriesMap = new HashMap();
		List<Bdictionary> kindList = new ArrayList<Bdictionary>();// 获取剧集列表
		List<Bdictionary> typeList = new ArrayList<Bdictionary>();// 获取剧情列表

		if (null != series.getChannel() && !series.getChannel().equals("")) {
			// 获取当前频道的剧集
			String kind = PlayStatisticsConfig.kind;
			kindList = bdictionaryService.dictionaryList(kind, series.getChannel());

			// 获取当前频道的剧情
			String type = PlayStatisticsConfig.type;
			typeList = bdictionaryService.dictionaryList(type, series.getChannel());
		}
		// 向map中添加剧集列表聚集列表
		dealSeriesMap.put("kindList", kindList);
		// 向map中添加剧集列表剧情列表
		dealSeriesMap.put("typeList", typeList);
		return dealSeriesMap;
	}

	// 默认进入未处理剧集页面时准备的初始化数据
	@Override
	public Map initializedData() {

		// TODO Auto-generated method stub
		// 将获取到的所有数据 存入map
		Map initializedMap = new HashMap();

		/* ================ 获取未处理剧集页面的初始化下拉框数据================ */
		List<Bdictionary> channelList = bdictionaryService.dictionaryList("channel", "");// 获取频道类型

		// List<Bdictionary> kindList = new ArrayList<Bdictionary>();// 获取剧集列表
		//
		// List<Bdictionary> typeList = new ArrayList<Bdictionary>();// 获取剧情列表

		Bdictionary channel = new Bdictionary();
		// 查询年份
		List<Bdictionary> yearsList = bdictionaryService.selectYear(channel);

		// 查询地区
		List<Bdictionary> areasList = bdictionaryService.selectArea(channel);

		// 查询语言
		List<Bdictionary> languageList = bdictionaryService.selectLanguage(channel);

		// 查询等级
		List<Bdictionary> PositionList = bdictionaryService.selectTypeByPosition(channel);

		// 向initializedMap中添加准备数据进行页面初始化
		initializedMap.put("channelList", channelList);
		initializedMap.put("yearsList", yearsList);
		initializedMap.put("areasList", areasList);
		initializedMap.put("languageList", languageList);
		initializedMap.put("PositionList", PositionList);
		return initializedMap;
	}

}
